<?php

namespace app\common\model\article;

use think\Model;
use think\model\concern\SoftDelete;

class Article extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $autoWriteTimestamp = 'datetime';

    public function user()
    {
        return $this->belongsTo('app\\common\\model\\user\\User', 'user_id');
    }

    public function tag()
    {
        return $this->belongsToMany('ArticleTag', 'ArticleAccessArticleTag');
    }

    public function type()
    {
        return $this->belongsToMany('ArticleType', 'ArticleAccessArticleType');
    }

    public function comment()
    {
        return $this->hasMany('ArticleComment');
    }

    public function know()
    {
        return $this->hasMany('ArticleKnow');
    }

    public function source()
    {
        return $this->hasMany('ArticleSource');
    }

    public function goods()
    {
        return $this->hasMany('ArticleGoods');
    }
    
    public function section()
    {
        return $this->belongsToMany('app\\common\\model\\book\\BookSection','ArticleAccessBookSection');
    }
}